# -*- encoding: UTF-8 -*-
from django.db import models

'''
CREATE TABLE nlc_user (
user_login_name char(15) NOT NULL DEFAULT '', //登录名
user_pass char(32) NOT NULL, //密码，需要用MD5加密后储存
user_web_name char(10) DEFAULT NULL, //网名，可为中文
user_gender char(1) DEFAULT '无', //性别
user_school char(20) DEFAULT '无', //学校
user_qq char(11) DEFAULT '无', //qq
user_phone char(11) DEFAULT NULL, //手机号
user_score int(11) DEFAULT '0', //评分
user_star_level int(1) DEFAULT '0', //星级
user_flag char(10) DEFAULT '新用户',
user_pic char(30) DEFAULT 'default_path',
user_ver_problem char(20) DEFAULT NULL,
user_ver_answer char(20) DEFAULT NULL,
PRIMARY KEY (user_login_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
'''


class User(models.Model):
    user_login_name = models.CharField(max_length=15, null=False, default='', primary_key=True, unique=True)
    user_pass = models.CharField(max_length=32, null=False, blank=False)
    user_web_name = models.CharField(max_length=10, default=None, unique=True)
    user_gender = models.CharField(max_length=1, default='无')
    user_school = models.CharField(max_length=20, default='无')
    user_qq = models.CharField(max_length=11, default='无')
    user_phone = models.CharField(max_length=11, null=True, blank=True)
    user_score = models.IntegerField(max_length=11, default='0')
    user_star_level = models.IntegerField(max_length=1, default=0)
    user_flag = models.CharField(max_length=10, default='新用户')
    user_pic = models.ImageField(null=True, blank=True, upload_to='/tmp/nlc/User_pic')
    user_ver_question = models.CharField(max_length=20, default=None)
    user_ver_answer = models.CharField(max_length=20, default=None)


"""
    CREATE TABLE nlc_group (
    group_login_name char(20) NOT NULL DEFAULT '新活动团体',
    group_pass char(32) NOT NULL,
    group_name char(20) NOT NULL DEFAULT '',
    group_school char(20) DEFAULT NULL,
    group_leader_name char(15) DEFAULT NULL,
    group_email char(20) DEFAULT NULL,
    group_pic char(30) DEFAULT 'default_path',
    group_score int(11) DEFAULT NULL,
    group_star_level int(11) DEFAULT '0',
    group_flag char(11) DEFAULT '推荐团体',
    group_ver_problem char(20) DEFAULT NULL,
    group_ver_answer char(20) DEFAULT NULL,
    PRIMARY KEY (group_login_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
"""


class Group(models.Model):
    group_login_name = models.CharField(max_length=20, primary_key=True, unique=True)
    group_pass = models.CharField(max_length=32)
    group_name = models.CharField(max_length=20, default='', unique=True)
    group_school = models.CharField(max_length=20, null=True, blank=True)
    group_leader_name = models.CharField(max_length=15, null=True, blank=True)
    group_email = models.CharField(max_length=20, null=True, blank=True)
    group_pic = models.ImageField(null=True, blank=True, upload_to='/tmp/nlc/Group_pic')
    group_score = models.IntegerField(max_length=11, default=0)
    group_star_level = models.IntegerField(max_length=11, default=0)
    group_flag = models.CharField(max_length=11, default='新注册团体')
    group_ver_question = models.CharField(max_length=20, default=None)
    group_ver_answer = models.CharField(max_length=20, default=None)

"""
CREATE TABLE nlc_activity (
ac_id int(11) unsigned NOT NULL AUTO_INCREMENT,
ac_title char(30) NOT NULL DEFAULT '',
ac_address char(30) NOT NULL,
ac_key_word char(8) DEFAULT NULL,
ac_start_time date NOT NULL DEFAULT '2015-01-01',
ac_end_time date NOT NULL DEFAULT '2015-11-11',
ac_content varchar(300) NOT NULL DEFAULT '',
ac_pics char(100) DEFAULT NULL,
ac_rank int(11) unsigned NOT NULL DEFAULT '1',
ac_score int(11) unsigned NOT NULL DEFAULT '0',
ac_flag char(11) DEFAULT '新活动',
ac_creator_type int(1) NOT NULL DEFAULT '0',
ac_creator_name char(20) NOT NULL DEFAULT '',
PRIMARY KEY (ac_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
"""


class Activity(models.Model):
    ac_id = models.AutoField(max_length=11, primary_key=True)
    ac_title = models.CharField(max_length=30, default='')
    ac_address = models.CharField(max_length=30, null=False, blank=False)
    ac_key_word = models.CharField(max_length=8, default=None)
    ac_start_time = models.DateField()
    ac_end_time = models.DateField()
    ac_content = models.CharField(max_length=300, default='')
    ac_pics = models.ImageField(null=True, blank=True, upload_to='/tmp/nlc/Activity_pic')
    ac_rank = models.IntegerField(max_length=11, default=1)
    ac_score = models.IntegerField(max_length=11, default=0)
    ac_flag = models.CharField(max_length=11, default='新活动')
    ac_creator_type = models.IntegerField(max_length=1, default=0)
    ac_creator_name = models.CharField(max_length=20, default='')